home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 310_02 / set.st < prev    next >
Text File  |  1990-04-18  |  531b  |  26 lines

  1. Class Set :Collection
  2. | list |
  3. [
  4.         new
  5.                 list <- List new
  6.  
  7. |       add: newElement
  8.         (list includes: newElement)
  9.             ifFalse: [list add: newElement]
  10.  
  11. |       remove: oldElement ifAbsent: exceptionBlock
  12.         list remove: oldElement ifAbsent: exceptionBlock
  13.  
  14. |       size
  15.                 ^ list size
  16.  
  17. |       occurrencesOf: anElement
  18.                 ^ (list includes: anElement) ifTrue: [1] ifFalse: [0]
  19.  
  20. |       first
  21.                 ^ list first
  22.  
  23. |       next
  24.                 ^ list next
  25. ]
  26.